import gfm from "@bytemd/plugin-gfm";
import highlight from "@bytemd/plugin-highlight";
import { Editor } from "@bytemd/react";
import "bytemd/dist/index.css";
import "highlight.js/styles/default.css";
import "github-markdown-css/github-markdown-light.css";
import "./index.css";

interface Props {
  value: string;
  onChange: (value: string) => void;
  placeholder?: string;
}
const plugins = [gfm(), highlight()];

/**
 * markdown编辑器配置
 */
const MdEditor = (props: Props) => {
  const { value = "", onChange, placeholder } = props;
  return (
    <div className="md-editor">
      <Editor
        value={value}
        onChange={onChange}
        placeholder={placeholder}
        plugins={plugins}
        mode="split"
      />
    </div>
  );
};
export default MdEditor;
